//
//  CYStatisticsTopView.m
//  CreditAddressBook
//
//  Created by Lee on 15/6/30.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "CYStatisticsTopView.h"
#import "CYStatistics.h"

@interface CYStatisticsTopView ()
@property (weak, nonatomic) IBOutlet UILabel *lastCallLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalDurationLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalTimes;
@property (weak, nonatomic) IBOutlet UILabel *averageLabel;

@end

@implementation CYStatisticsTopView

- (void)setStatis:(CYStatistics *)statis {
    self.lastCallLabel.text = [NSString stringWithFormat:@"最后一次通话:%@", statis.callRecord.newlyCallDate];
    self.totalDurationLabel.text = [NSString stringWithFormat:@"通话总时长:%@", statis.callRecord.callDurationSum];
    self.totalTimes.text = [NSString stringWithFormat:@"通话总次数:%@次", statis.callRecord.times];
    self.averageLabel.text = [NSString stringWithFormat:@"平均每%.1f天通话一次", statis.averageCallTimes];
}

+ (instancetype)topView {
    CYStatisticsTopView *top = [[[NSBundle mainBundle] loadNibNamed:@"CYStatisticsTopView" owner:nil options:nil] lastObject];
    if (top) {
        top.backgroundColor = [UIColor clearColor];
    }
    return top;
}

- (void)setFrame:(CGRect)frame {
    frame.size.width = CYScreeSize.width;
    [super setFrame:frame];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
